﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFrom登录注册增删改查
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static Dictionary<string, string> users = new Dictionary<string, string>();

        //设置一个静态。。。。
        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;//获取输入框值
            var pwd = textBox1.Text;//获取输入框值
            var urs = users.Where(x => x.Key == uid && x.Value == pwd)//转换
                .Select(x => new { key = x.Key, value = x.Value }).FirstOrDefault();//转换

            if(urs != null)
            {
                MessageBox.Show("登录成功!");
                Form3 form3 = new Form3();//跳转界面
                this.Hide();//关闭该界面
                form3.Show();//进入跳转界面
            }
            else
            {
                MessageBox.Show("登录失败。");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();//进入注册界面
            this.Hide();//关闭该界面
            form2.Show();//进入跳转界面
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           // users.Add("admins", "admin");//存值
        }
    }
}
